const express = require('express')
const route = express.Router();
//引入权限校验中间件
const isLoginMiddle = require("../middleware/isLoginMiddle")

const advModel = require("../db/model/advModel")
route.get('/getUpdateData',isLoginMiddle, async (req,res)=>{
    const {
        _id
    }=req.query

    //拿到id取数据库找到对应数据数据库返回一个对象的数据
    try{
        const findResult =  await advModel.findOne({
            _id
        })

        //把值给前端发过去
        res.send({
            code:10000,
            msg:'更新数据前查询当前数据成功',
            data:findResult
        })
    }catch(e){
        console.log("更新数据前查询失败" + e.message);
        res.send({
            code: 10001,
            msg: "更新数据前查询失败" + e.message,
            data: null
        })
    }
})
module.exports = route